package com.fyzk.activity.lottery.gaopin;

import android.view.View;

import com.fyzk.activity.app.AppToast;
import com.tyjc.lottery.R;
import com.fyzk.utils.HelpUrlConstants;
import com.fyzk.utils.LotteryIDUtils;

import java.util.ArrayList;

public class SD11x5Activity extends Gp11x5BaseActivity{

    @Override
    public boolean touZhu() {
        long zhuShu = getZhushu();
        if (zhuShu > 0) {
            int lotteryId = wanFaId;
            switch (wanFaId) {
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENBA_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENBA_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANYI_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANYI_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_TOWED_ID_INT:
                    if (zhuShu < 2) {
                        AppToast.getToast().show("胆拖至少选择2注");
                        return true;
                    } else {
                        break;
                    }

                default:
                    break;
            }

            touZhu1(lotteryId, zhuShu);
            return true;
        } else {
            return false;
        }

    }

    @Override
    public int getLotteryId() {
        return LotteryIDUtils.SD11XUAN5_LOTTERY_ID_INT;
    }

    @Override
    protected void popupClickItem(int arg2) {
        super.popupClickItem(arg2);
        switch (arg2) {
            case 0://任选2
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_DAN_ID_INT;
                setRenXuan(R.string.gp_11x5_prize_r2);
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 1://任选3
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_DAN_ID_INT;
                setRenXuan(R.string.gp_11x5_prize_r3);
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 2://任选4
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_DAN_ID_INT;
                setRenXuan(R.string.gp_11x5_prize_r4);
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 3://任选5
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_DAN_ID_INT;
                setRenXuan(R.string.gp_11x5_prize_r5);
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 4://任选6
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_DAN_ID_INT;
                setRenXuan(R.string.gp_11x5_prize_r6);
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 5://任选7
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_DAN_ID_INT;
                setRenXuan(R.string.gp_11x5_prize_r7);
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 6://任选8
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENBA_DAN_ID_INT;
                setRenXuan(R.string.gp_11x5_prize_r8);
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 7://前一
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANYI_DAN_ID_INT;
                setRenXuan(R.string.gp_11x5_prize_q1);
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 8://前二直选
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_DAN_ID_INT;
                ball_ll_dan.setVisibility(View.GONE);
                ball_ll_two.setVisibility(View.VISIBLE);
                ball_ll_three.setVisibility(View.GONE);
                prize_tishi_tv.setText(R.string.gp_11x5_prize_q2);
                balltitle_first.setText(getString(R.string.gp_11xuan5_balltitle_wan));
                ball_tiShi_first.setText("");
                balltitle_two.setText(getString(R.string.gp_11xuan5_balltitle_qian));
                ball_tiShi_two.setText("");
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 9://前二组选
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_DAN_ID_INT;
                setRenXuan(R.string.gp_11x5_prize_q2_zu);
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 10://前三直选
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_DAN_ID_INT;
                ball_ll_dan.setVisibility(View.GONE);
                ball_ll_two.setVisibility(View.VISIBLE);
                ball_ll_three.setVisibility(View.VISIBLE);
                prize_tishi_tv.setText(R.string.gp_11x5_prize_q3);
                balltitle_first.setText(getString(R.string.gp_11xuan5_balltitle_wan));
                ball_tiShi_first.setText("");
                balltitle_two.setText(getString(R.string.gp_11xuan5_balltitle_qian));
                ball_tiShi_two.setText("");
                balltitle_three.setText(getString(R.string.gp_11xuan5_balltitle_bai));
                ball_tiShi_three.setText("");
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 11://前三组选
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_DAN_ID_INT;
                setRenXuan(R.string.gp_11x5_prize_q3_zu);
                shake_random_ll.setVisibility(View.VISIBLE);
                break;
            case 12://任选二胆拖
                prize_tishi_tv.setText(R.string.gp_11x5_prize_r2_dan);
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_TOWED_ID_INT;
                setDanTuo(R.string.gp_11x5_r2_dan, DAN_REN2);
                shake_random_ll.setVisibility(View.GONE);
                break;
            case 13://任选三胆拖
                prize_tishi_tv.setText(R.string.gp_11x5_prize_r3_dan);
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_TOWED_ID_INT;
                setDanTuo(R.string.gp_11x5_r3_dan, DAN_REN3);
                shake_random_ll.setVisibility(View.GONE);
                break;
            case 14://任选四胆拖
                prize_tishi_tv.setText(R.string.gp_11x5_prize_r4_dan);
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_TOWED_ID_INT;
                setDanTuo(R.string.gp_11x5_r4_dan, DAN_REN4);
                shake_random_ll.setVisibility(View.GONE);
                break;
            case 15://任选五胆拖
                prize_tishi_tv.setText(R.string.gp_11x5_prize_r5_dan);
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_TOWED_ID_INT;
                setDanTuo(R.string.gp_11x5_r5_dan, DAN_REN5);
                shake_random_ll.setVisibility(View.GONE);
                break;
            case 16://任选六胆拖
                prize_tishi_tv.setText(R.string.gp_11x5_prize_r6_dan);
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_TOWED_ID_INT;
                setDanTuo(R.string.gp_11x5_r6_dan, DAN_REN6);
                shake_random_ll.setVisibility(View.GONE);
                break;
            case 17://任选七胆拖
                prize_tishi_tv.setText(R.string.gp_11x5_prize_r7_dan);
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_TOWED_ID_INT;
                setDanTuo(R.string.gp_11x5_r7_dan, DAN_REN7);
                shake_random_ll.setVisibility(View.GONE);
                break;
            case 18://前二组选胆拖
                prize_tishi_tv.setText(R.string.gp_11x5_prize_q2_zu_dan);
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_TOWED_ID_INT;
                setDanTuo(R.string.gp_11x5_q2_zu_dan, DAN_QIAN2_ZHI);
                shake_random_ll.setVisibility(View.GONE);
                break;
            case 19://前三组选胆拖
                prize_tishi_tv.setText(R.string.gp_11x5_prize_q3_zu_dan);
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_TOWED_ID_INT;
                setDanTuo(R.string.gp_11x5_q3_zu_dan, DAN_QIAN3_ZHI);
                shake_random_ll.setVisibility(View.GONE);
                break;

            default:
                break;
        }
        addMissValue();
        getMissValueList();

    }

    @Override
    public void randomBallNum() {
        // TODO Auto-generated method stub
        clear();
        switch (wanFaId) {
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_DAN_ID_INT;
                randomRen(2);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_DAN_ID_INT;
                randomRen(3);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_DAN_ID_INT;
                randomRen(4);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_DAN_ID_INT;
                randomRen(5);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_DAN_ID_INT;
                randomRen(6);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_DAN_ID_INT;
                randomRen(7);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENBA_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENBA_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENBA_DAN_ID_INT;
                randomRen(8);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANYI_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANYI_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANYI_DAN_ID_INT;
                randomRen(1);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_DAN_ID_INT;
                randomRen(2);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_DAN_ID_INT;
                randomRen(3);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_DAN_ID_INT;
                randomZhi(2);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_DAN_ID_INT;
                randomZhi(3);
                break;
            default:
                break;
        }

        ballView_dan.invalidate();
        ballView_first.invalidate();
        ballView_two.invalidate();
        ballView_three.invalidate();

        ballClick();

    }

    @Override
    public String getHelpUrl() {
        // TODO Auto-generated method stub
        return HelpUrlConstants.Help_SD115;
    }

    @Override
    public String getHelpTitle() {
        // TODO Auto-generated method stub
        return getString(R.string.help_11xuan5);
    }

    @Override
    protected void addMissValue() {
        super.addMissValue();
        if (missInfo != null) {
            if (popup_itemsId[popupId] == R.string.gp_11xuan5_popu_qian1) {
                ballView_first.setMissValues(missInfo.missValue("2007MV_Q1").get(0));
            }else if (popup_itemsId[popupId] == R.string.gp_11xuan5_popu_qian2_zhi) {
                ballView_first.setMissValues(missInfo.missValue("2007MV_Q2").get(0));
                ballView_two.setMissValues(missInfo.missValue("2007MV_Q2").get(1));
            } else if (popup_itemsId[popupId] == R.string.gp_11xuan5_popu_qian3_zhi) {
                ballView_first.setMissValues(missInfo.missValue("2007MV_Q3").get(0));
                ballView_two.setMissValues(missInfo.missValue("2007MV_Q3").get(1));
                ballView_three.setMissValues(missInfo.missValue("2007MV_Q3").get(2));
            } else if (popup_itemsId[popupId] == R.string.gp_11xuan5_popu_qian2_zu) {
                ballView_first.setMissValues(missInfo.missValue("2007MV_Q2Z").get(0));
            } else if (popup_itemsId[popupId] == R.string.gp_11xuan5_popu_qian2_zu_dan) {
                ballView_first.setMissValues(missInfo.missValue("2007MV_Q2Z").get(0));
                ballView_dan.setMissValues(missInfo.missValue("2007MV_Q2Z").get(0));
            } else if (popup_itemsId[popupId] == R.string.gp_11xuan5_popu_qian3_zu) {
                ballView_first.setMissValues(missInfo.missValue("2007MV_Q3Z").get(0));
            } else if (popup_itemsId[popupId] == R.string.gp_11xuan5_popu_qian3_zu_dan) {
                ballView_first.setMissValues(missInfo.missValue("2007MV_Q3Z").get(0));
                ballView_dan.setMissValues(missInfo.missValue("2007MV_Q3Z").get(0));
            } else {
                ballView_first.setMissValues(missInfo.missValue("2007MV_RX").get(0));
                ballView_dan.setMissValues(missInfo.missValue("2007MV_RX").get(0));
            }
        } else {
            ballView_first.setMissValues(new ArrayList<Integer>());
            ballView_two.setMissValues(new ArrayList<Integer>());
            ballView_three.setMissValues(new ArrayList<Integer>());
            ballView_dan.setMissValues(new ArrayList<Integer>());
        }
//        getMissValueList();

    }
}
